﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BuildnDeploy {
    /// <summary>
    /// Interaction logic for OutputTab.xaml
    /// </summary>
    public partial class OutputTab : UserControl {
        public OutputTab() {
            InitializeComponent();
        }
        public void Write(string text) {
            this.Dispatcher.Invoke(new Action(() =>
            {
                Out.Text += text;
                scrollViewer.ScrollToEnd();
            }));
        }

        public void WriteLine(string text) {
            this.Dispatcher.Invoke(new Action(() =>
            {
                Out.Text += text + Environment.NewLine;
                scrollViewer.ScrollToEnd();
            }));
        }

        public void WriteLine(string text, params object[] args) {
            this.Dispatcher.Invoke(new Action(() =>
            {
                Out.Text += string.Format(text, args) + Environment.NewLine;
                scrollViewer.ScrollToEnd();
            }));
        }

        public void Write(string text, params object[] args) {
            this.Dispatcher.Invoke(new Action(() =>
            {
                Out.Text += string.Format(text, args);
                scrollViewer.ScrollToEnd();
            }));
        }

        private void ClearMenuItem_Click(object sender, RoutedEventArgs e) {
            this.Dispatcher.Invoke(new Action(() =>
            {
                Out.Text = "";
            }));
        }
    }
}
